********************************************************************************************************************************
***   Replication file for:                                                                                                  ***
***   Berbee, P., Braun, S. T. and Franke, R. (2024). Reversing Fortunes of German Regions, 1926-2019. JoEG.			     ***
***   							                                                                                             ***
***   SCRIPT: 	_x3a_preparation_turnover_1926.do																			 ***	
***   PURPOSE: 	Reads in and prepares turnover data from 1926															 	 ***
********************************************************************************************************************************

* Preamble (unnecessary when executing run.do)
run "$reversing/scripts/programs/_config.do"

************
* Code begins
************

*** Import data

import excel "$reversing/data/turnover1926.xlsx", sheet("Data") firstrow clear
drop A T_ID
rename huv_u h_u

* Create some globals that facilitate labeling of variables
global l_in "insgesamt"
global l_l "Landwirtschaft (insges.)"
global l_lk "Landwirtschaft (Kleinums.)"
global l_i "Industrie"
global l_h "Handel und Transport"
global l_s "Staat/öffentl.Hand"

global m_veran "Veranlagte"
global m_u "Umsatz (1000RM)"
global m_stbel "Steuerbelastete"
global m_st "Umstatzsteuer(1000RM)"


* label variables and change names
foreach sect in in l lk i h s{
foreach var in veran u stbel st{
label var `sect'_`var' "${m_`var'} ${l_`sect'} (1926)"
rename `sect'_`var' `sect'_`var'_1926
}
}

gen turnover=in_u_1926
gen turnover_agr=l_u_1926
gen turnover_ind=i_u_1926
gen turnover_trade=h_u_1926
gen turnover_public=s_u_1926


* Rename and create matching variables
rename pop1925 population
rename Sheet1__La labor_market_id
gen year=1926

*** Save data
keep labor_market_id population turnover year
destring labor_market_id, replace
sort labor_market_id

save "$reversing/processed/intermediate/turnover1926.dta",replace

*** EOF

